package com.cbank.utils;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

/*********************************
 *
 * 短信发送接口调用类
 *
 * @author YangJin
 *
 ********************************/
public class MessageUtil {

	private static String Url = "http://106.ihuyi.cn/webservice/sms.php?method=Submit";
	private static Logger logger = Logger.getLogger(MessageUtil.class);
	public static void transmessage(String phone,String content) {

		try {
			Map<String, String> params = new HashMap<String, String>(6);
			params.put("account", "cf_wopiao");
			params.put("password", "love5656");
			params.put("mobile", phone);
			params.put("content", content);

			String SubmitResult = HttpClientUtils.simplePostInvoke(Url, params);

			logger.info(SubmitResult);

			Document doc = DocumentHelper.parseText(SubmitResult);
			Element root = doc.getRootElement();

			String code = root.elementText("code");
			String msg = root.elementText("msg");
			String smsid = root.elementText("smsid");

			logger.info("code : " + code + ",msg : " + msg + ",smsid : " + smsid);

		} catch (Exception e) {

		}
	}
	public static void main(String[] args) {
		
//		MessageUtil.transmessage("7656（绑定手机验证码）如非本人操作，请忽略本短信。");
		
//		try {
//			
//			Map<String, String> params = new HashMap<String, String>(6);
//			params.put("account", "cf_wopiao");
//			params.put("password", "love5656");
//			params.put("mobile", "15801377079");
//			params.put("content", "7666（绑定手机验证码）如非本人操作，请忽略本短信。");
//
//			String SubmitResult = HttpClientUtils.simplePostInvoke(Url, params);
//
//			
//			//System.out.println(SubmitResult);
//
//			Document doc = DocumentHelper.parseText(SubmitResult); 
//			Element root = doc.getRootElement();
//
//
//			String code = root.elementText("code");	
//			String msg = root.elementText("msg");	
//			String smsid = root.elementText("smsid");	
//			
//			
//			System.out.println(code);
//			System.out.println(msg);
//			System.out.println(smsid);
//						
//			 if("2".equals(code)){
//				System.out.println("短信提交成功");
//			}
//			
//		} catch (Exception e) {
//			e.printStackTrace();
//		} 	
		
	
	}
}
